package com.bdmc.smokesensor.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.bdmc.smokesensor.Utils.Msg;
import com.bdmc.smokesensor.Utils.ResultUtil;
import com.bdmc.smokesensor.iservices.ISmk_AlarmService;
import com.bdmc.smokesensor.iservices.ISmk_BuildingsService;
import com.bdmc.smokesensor.iservices.ISmk_GroupCompanyService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(value = "/screen", method = RequestMethod.POST)
public class BigScreenController extends BaseController {

    @Autowired
    private ISmk_AlarmService _alarmSvs;

    @Autowired
    private ISmk_GroupCompanyService _gcSvs;

    @Autowired
    private ISmk_BuildingsService _buildSvs;

    @RequestMapping(value = "/chart")
    public Msg statistic() {
        int dep_id = Integer.valueOf(request.getAttribute("dep_id").toString());
        Map<String, Object> results = new HashMap<String, Object>();
        results.put("alarmStatChart", _alarmSvs.findAlarmStatGroupInfo(dep_id));
        results.put("alarmTypeChart", _alarmSvs.findAlarmTypeGroupInfo(dep_id));
        results.put("alarmFullYearChart", _alarmSvs.findAlarmTypeFullYear(dep_id));
        results.put("alarmDepChart", _alarmSvs.findAlarmTypeGroupByDep(dep_id));
        results.put("depCount", _gcSvs.findAreaGcBdDevSum(dep_id));
        return ResultUtil.success(results);
    }

    // 获取商户信息
    @RequestMapping(value = "/shops")
    public Msg getShops() {
        int dep_id = Integer.valueOf(request.getAttribute("dep_id").toString());
        List<Map<String, Object>> shops = _buildSvs.findBuildingsByDepid(dep_id);
        return ResultUtil.success(shops);
    }
}